package com.jy.wms.controller;

import com.joyi.gate.comm.SessionInfo;
import com.joyi.gate.safety.vo.UserInfo;
import com.jy.wms.common.SetStatus;
import com.jy.wms.common.base.BaseSessionInfo;
import com.jy.wms.pojo.SysHz;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.jy.wms.common.base.BaseController;
import com.jy.wms.common.base.JsonResult;
import com.jy.wms.pojo.WmsQualityHistory;
import com.jy.wms.service.WmsQualityHistoryService;
import javax.servlet.http.HttpSession;
import com.github.pagehelper.Page;
import com.jy.wms.common.base.ResultPage;
import java.util.List;
import com.jy.wms.common.UUIDUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * @ClassName: WmsQualityHistoryController
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @Author Jane
 * @Date Wed Dec 13 14:08:44 CST 2017
 */
@Controller
@RequestMapping("/wmsqualityhistory")
@Api(value = "/wmsqualityhistory", description = "质检单 查询库位出库详细信息")
public class  WmsQualityHistoryController extends BaseController<WmsQualityHistoryService,WmsQualityHistory> {

    @PostMapping(value="/list")
    @ApiOperation(value = "质检单 POST请求查询质检出库库位明细",response = JSONObject.class, notes = "POST请求查询质检出库库位明细")
    public  @ResponseBody JSONObject getWmsPacking(@RequestBody WmsQualityHistory entity,HttpSession session) {
        Page<WmsQualityHistory> list = new Page<WmsQualityHistory>();
        JSONObject json = getJSONObject();
        try {

                list=baseService.baseSelectPage(entity);
            json = SetStatus.setSearchType(JSONArray.fromObject(list).toString(),(int) list.getTotal());
        }catch (Exception e) {
            e.printStackTrace();
        }
        return json;
    }
    @PostMapping(value = "delete")
    @ApiOperation(value = "删除信息",response = JSONObject.class, notes = "删除信息")
    public @ResponseBody JsonResult deleteWmsQualityHistory(@RequestBody List<String> ids) {
        Integer flag=baseService.baseDeleteBathPrimaryKeys(ids);
        return renderSuccess("删除成功");
    }

    @PostMapping(value = "add")
    @ApiOperation(value = "新增信息",response = JSONObject.class, notes = "新增信息")
    public @ResponseBody JsonResult addWmsQualityHistory(@RequestBody WmsQualityHistory entity) {
        baseService.baseInsert(entity);
        return renderSuccess("添加成功");
    }

    @GetMapping(value = "getWmsQualityHistory/{id}")
    @ApiOperation(value = "查看单个信息",response = JSONObject.class, notes = "GET查看单个信息")
    public @ResponseBody WmsQualityHistory getWmsQualityHistoryById(@PathVariable("id") String id) {
        WmsQualityHistory entity=baseService.baseSelectByPrimaryKey(id);
        return entity;
    }
    @PostMapping(value = "edit")
    @ApiOperation(value = "编辑信息",response = JSONObject.class, notes = "编辑信息")
    public @ResponseBody JsonResult editWmsQualityHistory(@RequestBody WmsQualityHistory entity) {
        Integer flag=baseService.baseUpdateByPrimaryKeySelective(entity);
        return renderSuccess("修改成功");
    }
}
